/**
 * 
 */
package Test;


import junit.framework.TestCase;

import org.junit.Before;
import org.junit.Test;

import data.LMA;

/**
 * This class performs basic unit testing functionality for the LMA class.
 * 
 * @author Stephen Amos
 * @version 1.0
 */
public class LMATest extends TestCase {
	/**
	 * LMA.
	 */
	private LMA test_lma;
	/**
	 * Organization name.
	 */
	private String organization;
	/**
	 * username.
	 */
	private String username;
	/**
	 * password.
	 */
	private String password;
	/**
	 * phone.
	 */
	private String phone;
	/**
	 * email.
	 */
	private String email;
	
	/**
	 * This method instantiates a LMA object, and populates it with
	 * a set of test field values. 
	 */
	@Before
	public void setUp() throws Exception {
		organization = "organization";
		username = "username";
		password = "password";
		phone = "123-456-7890";
		email = "LMA@email.com";
		test_lma = new LMA(organization, username, password, phone, email);
	}
	
	/**
	 * This method tests a LMA object's constructor.
	 * 
	 * 1) Test whether the LMA object's organization field has been created
	 * successfully with the correct data.
	 * 2) Test whether the LMA object's firstname field has been created
	 * successfully with the correct data.
	 * 3) Test whether the LMA object's surname field has been created
	 * successfully with the correct data.
	 * 4) Test whether the LMA object's username field has been created
	 * successfully with the correct data.
	 * 5) Test whether the LMA object's password field has been created
	 * 
	 * All assertions in this method should return true.  If one or more
	 * assertion fails, the constructor has failed to create a LMA object
	 * as intended.
	 */
	@Test
	public void testLMA() {
		String test_organization = test_lma.getOrganization();
		String test_username = test_lma.getUsername();
		String test_password = test_lma.getPassword();
		String test_phone = test_lma.getPhone();
		String test_email = test_lma.getEmail();
		
		assertEquals("Organization assertion failed.", test_organization.equals(organization), true);
		assertEquals("Username assertion failed.", test_username.equals(username), true);
		assertEquals("Password assertion failed.", test_password.equals(password), true);
		assertEquals("Phone assertion failed.", test_phone.equals(phone), true);
		assertEquals("Email assertion failed.", test_email.equals(email), true);
	}
	
	/**
	 * Tests whether the equals method for the LMA class functions
	 * as intended.
	 * 
	 * 1) This assertion passes if the objects are equal. 
	 * 
	 * All assertions in this method should return true.  If one or more
	 * assertion fails, the equals method has failed to function as intended
	 * for the LMA class.
	 */
	@Test
	public void testEquals() {
		String organization = "organization";
		String username = "username";
		String password = "password";
		String phone = "123-456-7890";
		String email = "LMA@email.com";
		LMA test_lma2 = new LMA(organization, username, password, phone, email);
		
		assertEquals("Equals assertion failed.", test_lma.equals(test_lma2), true);
	}
	
	/**
	 * This test determines whether the compareTo() method functions as intended
	 * for the LMA class.
	 * 
	 * 1) Tests whether the compared object is alphabetically equal.
	 * 2) Tests whether the compared object is alphabetically higher.
	 * 3) Tests whether the compared object is alphabetically lower.
	 * 
	 * All assertions in this method should return true.  If one or more
	 * assertion fails, the compareTo() method has failed to function as intended
	 * for the LMA class.
	 */
	@Test
	public void testCompare() {
		String username = "username";
		String password = "password";
		String phone = "123-456-7890";
		String email = "LMA@email.com";
		LMA test_lma2 = new LMA("aaa", username, password, phone, email);
		
		LMA test_lma3 = new LMA("zzz", username, password, phone, email);
		
		assertEquals("compareTo assertion failed.", test_lma.compareTo(test_lma) == 0, true);
		assertEquals("compareTo assertion failed.", test_lma.compareTo(test_lma2) > 0, true);
		assertEquals("compareTo assertion failed.", test_lma.compareTo(test_lma3) < 0, true);
	}
	
	/**
	 * Tests whether the toString() method for an LMA object functions
	 * as intended.
	 * 
	 * 1) Assert whether the toString() method for the LMA class functions as intended.
	 * 
	 * All assertions in this method should return true.  If one or more
	 * assertion fails, the toString() method has failed to function as intended
	 * for the LMA class.
	 */
	@Test
	public void testString() {
		String test_string = "organization,,username,,password,,123-456-7890,,LMA@email.com\n";
		
		assertEquals("toString assertion failed.", test_lma.toString().equals(test_string), true);
	}
	
	

}
